<template>
	<view class="admin-user-item-container" @tap="goDetail">
		<image src="../../static/logo.png" mode="widthFix"></image>
		<view>
			<view class="admin-user-item">
				<view class="admin-user-item-label">用户名</view>：
				<view class="admin-user-item-value">{{data.userInfo.username}}</view>
			</view>
			<view class="admin-user-item">
				<view class="admin-user-item-label">昵称</view>：
				<view class="admin-user-item-value">{{data.userInfo.nickname}}</view>
			</view>
			<view class="admin-user-item">
				<view class="admin-user-item-label">权限</view>：
				<view class="admin-user-item-value">{{data.role[data.userInfo.role]}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {onMounted,reactive,watch} from 'vue'
	export default{
		name:"admin-user-item",
		setup(props,context){
			let data = reactive({
				userInfo:{},
				role:['普通用户','管理员','超级管理员']
			})
			
			onMounted(()=>{
				data.userInfo = props.userInfo
			})
			
			watch(props, (newProps)=>{
			    data.userInfo = newProps.userInfo
			})
			
			function goDetail(){
				uni.navigateTo({
					url:"/page_admin/admin/admin-user-detail?userInfo="+encodeURIComponent(JSON.stringify(props.userInfo))
				})
			}
			
			return {
				data,
				goDetail
			}
		}
	}
</script>

<style lang="scss" scoped>
	.admin-user-item-container{
		padding: 10rpx;
		margin: 20rpx 0;
		display: flex;
		height: 120rpx;
		align-items: center;
		border-bottom: 2rpx solid #515151;
		
		& image{
			width: 100rpx;
			border-radius: 200rpx;
		}
		
		& .admin-user-item{
			display: flex;
			margin-left: 30rpx;
		}
	}
</style>